package bsc.ejb.entity;

import bsc.ejb.metadata.Colorimetry;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author memozac
 */
@Entity
public class ActionPlan implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long idActionPlan;
    @Column(columnDefinition = "text")
    private String title;
    @Column(columnDefinition = "text")
    private String description;
    @Temporal(value = TemporalType.DATE)
    private Date ActionPlanInitialDate;
    @Temporal(value = TemporalType.DATE)
    private Date ActionPlanEndDate;

    

    public enum Status{DELAYED,IN_PROCESS,COMPLETED,UNINITIALIZE};

    @Enumerated
    private Status status;


    @ManyToOne
    private Colorimetry colorimetry;

    @ManyToOne
    private ScoreCard scoreCard;

    @ManyToMany(targetEntity = Person.class)
    @JoinTable(name = "ActionPlanPerson",
    joinColumns = @JoinColumn(name = "idActionPlan"),
    inverseJoinColumns = @JoinColumn(name = "idPerson"))
    private Collection<Person> persons;
    
    @OneToMany
    private List<Attachment> attachments;

    public ScoreCard getScoreCard() {
        return scoreCard;
    }

    public void setScoreCard(ScoreCard scoreCard) {
        this.scoreCard = scoreCard;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public List<Attachment> getAttachments() {
        return attachments;
    }

    public void setAttachments(List<Attachment> attachments) {
        this.attachments = attachments;
    }

    public Long getIdActionPlan() {
        return idActionPlan;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idActionPlan != null ? idActionPlan.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof ActionPlan)) {
            return false;
        }
        ActionPlan other = (ActionPlan) object;
        if ((this.idActionPlan == null && other.idActionPlan != null) || (this.idActionPlan != null && !this.idActionPlan.equals(other.idActionPlan))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "bsc.ejb.entity.ActionPlan[id=" + idActionPlan + "]";
    }

    /**
     * @return the persons
     */
    public Collection<Person> getPersons() {
        return persons;
    }

    /**
     * @param persons the persons to set
     */
    public void setPersons(Collection<Person> persons) {
        this.persons = persons;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @param description the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @return the ActionPlanInitialDate
     */
    public Date getActionPlanInitialDate() {
        return ActionPlanInitialDate;
    }

    /**
     * @param ActionPlanInitialDate the ActionPlanInitialDate to set
     */
    public void setActionPlanInitialDate(Date ActionPlanInitialDate) {
        this.ActionPlanInitialDate = ActionPlanInitialDate;
    }

    /**
     * @return the ActionPlanEndDate
     */
    public Date getActionPlanEndDate() {
        return ActionPlanEndDate;
    }

    /**
     * @param ActionPlanEndDate the ActionPlanEndDate to set
     */
    public void setActionPlanEndDate(Date ActionPlanEndDate) {
        this.ActionPlanEndDate = ActionPlanEndDate;
    }

    /**
     * @return the status
     */
    public Status getStatus() {
        return status;
    }

    /**
     * @param status the status to set
     */
    public void setStatus(Status status) {
        this.status = status;
    }

    /**
     * @return the colorimetry
     */
    public Colorimetry getColorimetry() {
        return colorimetry;
    }

    /**
     * @param colorimetry the colorimetry to set
     */
    public void setColorimetry(Colorimetry colorimetry) {
        this.colorimetry = colorimetry;
    }
}//ends of class

